package com.ddtech.business.dance.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ddtech.business.dance.entity.Dancer;
import com.ddtech.business.dance.entity.StandardDance;
import com.ddtech.business.dance.mapper.DancerMapper;
import com.ddtech.business.dance.service.DancerService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @version v1.0
 * @ClassName:DancerServiceImpl description：
 * @author:wei_zhang(xiao)
 * @date: 2024-07-16 14:09
 */
@Service
public class DancerServiceImpl extends ServiceImpl<DancerMapper, Dancer> implements DancerService {

    @Override
    public void saveDancer(StandardDance standardDance, List<Dancer> list) {
        for(Dancer dancer : list){
            dancer.setStandardDanceId(standardDance.getId());
            dancer.init();
            this.saveOrUpdate(dancer);
        }
    }

    @Override
    public List<Dancer> queryByStandardDanceId(String standardDanceId) {
        LambdaQueryWrapper<Dancer> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Dancer::getStandardDanceId, standardDanceId);
        queryWrapper.orderByAsc(Dancer::getCreateTime);
        return this.list(queryWrapper);
    }
}
